package cn.itcast.dao.impl;


import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import cn.itcast.dao.ChapterContentDao;
import cn.itcast.mapper.ChapterContentMapper;
import cn.itcast.util.MybatisUtil;
import cn.itcast.vo.ChapterContent;

public class ChapterContentDaoImpl implements ChapterContentDao{
	private SqlSessionFactory sqlSessionFactory;

	public ChapterContentDaoImpl() {
	    sqlSessionFactory=MybatisUtil.getSqlSessionFactory();
	    System.out.println("SqlSessionFactory工厂:"+sqlSessionFactory.toString());
	}

	@Override
	public List<ChapterContent> getChapterContentByChapterId(int id) {
		List<ChapterContent> list= null;
		SqlSession sqlSession = sqlSessionFactory.openSession();
		ChapterContentMapper chapterContentMapper=sqlSession.getMapper(ChapterContentMapper.class);
		list=chapterContentMapper.getChapterContentByChapterId(id);
		
		sqlSession.close();
		return list;
		
	}
	public static void main(String[] args) {
	new ChapterContentDaoImpl().getChapterContentByChapterId(3);
	}
	
	

}
